package picol.view.component;

import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JTextArea;

/**
 *
 * @author Aurélien Marcel - Julien Sanderson
 */
public class MemoryFrame extends JFrame {

    private static int frame_width = 150;
    private static int frame_height = 600;
    private int pos;
    private JTextArea text;

    public MemoryFrame() {
    }

    public MemoryFrame(int pos) {
        super("Memory");
        this.pos = pos + this.frame_width;
        this.init();
        this.pack();
        this.setSize(frame_width, frame_width);
        this.position(frame_width, frame_height);
        this.setVisible(true);
    }

    private void init() {
        this.text = new JTextArea(frame_width, frame_height);
        this.add(text);
    }

    private void position(int _width, int _height) {

        Dimension tailleEcran = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (tailleEcran.width - (_width - this.pos) + 10) / 2;
        int y = (tailleEcran.height - _height) / 2;
        this.setBounds(x, y, _width, _height);
    }

    public void setMemoryList(String varList) {
        this.text.setText(varList);
    }
}
